import api from './auth.js'

// 获取学生列表
export const getStudentList = (params) => {
  return api.get('/api/admin/student-manage/list', { params })
    .then(response => {
      return response
    })
    .catch(error => {
      console.error('获取学生列表失败:', error)
      throw error
    })
}

// 获取学生详细信息
export const getStudentDetail = (id) => {
  return api.get(`/api/admin/student-manage/${id}`)
    .then(response => {
      return response
    })
    .catch(error => {
      console.error('获取学生详情失败:', error)
      throw error
    })
}

// 锁定学生账户
export const lockStudent = (id) => {
  return api.post(`/api/admin/student-manage/lock/${id}`)
    .then(response => {
      return response
    })
    .catch(error => {
      console.error('锁定学生账户失败:', error)
      throw error
    })
}

// 解锁学生账户
export const unlockStudent = (id) => {
  return api.post(`/api/admin/student-manage/unlock/${id}`)
    .then(response => {
      return response
    })
    .catch(error => {
      console.error('解锁学生账户失败:', error)
      throw error
    })
}

// 更新学生信息
export const updateStudent = (id, data) => {
  return api.put(`/api/admin/student-manage/${id}`, data)
    .then(response => {
      return response
    })
    .catch(error => {
      console.error('更新学生信息失败:', error)
      throw error
    })
}

// 禁用学生账户
export const disableStudent = (id) => {
  return api.post(`/api/admin/student-manage/disable/${id}`)
    .then(response => {
      return response
    })
    .catch(error => {
      console.error('禁用学生账户失败:', error)
      throw error
    })
}

// 解封学生账户
export const enableStudent = (id) => {
  return api.post(`/api/admin/student-manage/enable/${id}`)
    .then(response => {
      return response
    })
    .catch(error => {
      console.error('解封学生账户失败:', error)
      throw error
    })
} 